<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<style>
<!--
.fromDate span.error {
position: absolute !important;
left: 310px;
}
-->
</style>
<div class="pageContent">
    <form method="post" action="${rc.getContextPath()}/manage/user/saveUser" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
        <div class="pageFormContent">
            <fieldset>
                <input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (user.userCode)??>${user.userCode!''}</#if>"> <input type="hidden" id="org" name="org" value="${org!''}"> <input type="hidden" id="role" name="role" value="${role!''}">
                <dl class="nowrap">
                    <div style="float: left; height: 25px; width: 300px;">
                        <label style="width:60px"><@label key="userCode.C,colon">用户编码：</@label></label> <input class="required alphanumeric toUp" name="userCode" value="<#if (user.userCode)??>${user.userCode!''}</#if>" size="20" type="text" maxlength="40"<#if (user.userCode)??> readonly="readonly"<#else> remote="${rc.getContextPath()}/manage/user/checkedUserCodeExits"</#if>
                        warn="<@label key="userCodeExist.M">用户编号已经存在</@label>"/>
                    
                    </div>
                    <div style="float: left; height: 25px; width: 300px;">
                        <label style="width:60px"><@label key="userText.C,colon">用户描述：</@label></label> <input class="required" name="userText" value="<#if (user.userText)??>${user.userText!''}</#if>" size="20" type="text" maxlength="60" />
                    </div>
                </dl>
                <dl class="nowrap">
                    <dd>
                        <div class="tabs" currentIndex="0" eventType="click" style="width: 615px;">
                            <div class="tabsHeader">
                                <div class="tabsHeaderContent">
                                    <ul>
                                        <li><a href="javascript:;"><span><@label key="detail.C">详情</@label></span> </a></li>
                                        <li><a href="javascript:;"><span><@label key="contact.C">联系</@label></span> </a></li>
                                        <li><a href="javascript:;"><span><@label key="organization.C">组织</@label></span> </a></li>
                                        <li><a href="javascript:;"><span><@label key="role.C">角色</@label></span> </a></li>
                                        <li><a href="javascript:;"><span><@label key="parameter.C">参数</@label></span> </a></li>
                                    </ul>
                                </div>
                            </div>
                            <div class="tabsContent">
                                <div style="height:252px">
                                    <p>
                                        <label><@label key="languageCode.C,colon">语言：</@label></label> <select style="width: 200px" name="languageCode" class="required" id="languageCode"> <#list languages as lan>
                                            <option value="${lan.languageCode}"<#if (user.languageCode)?? && (user.languageCode == lan.languageCode)> selected</#if>>${lan.languageName}</option> </#list>
                                        </select>
                                    </p>

                                    <p>
                                        <label><@label key="timeZoneCode.C,colon">时区：</@label></label> <select style="width: 200px" name="timeZoneCode" class="required" id="timeZoneCode"> <#list timezones as tzs>
                                            <option value="${tzs.timeZoneCode!''}"<#if (user.timeZoneCode)?? && (user.timeZoneCode == tzs.timeZoneCode)> selected</#if>>${tzs.timeZoneName}</option> </#list>
                                        </select>
                                    </p>
                                    <p class="fromDate">
                                        <label><@label key="fromDate.C,colon">有效期自：</@label></label> <input style="width: 168px" type="text" name="fromDateStr" class="date required" value="<#if (user.fromDateStr)??>${user.fromDateStr!''}</#if>" /> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                                    </p>
                                    <p>
                                        <label><@label key="toDate.C,colon">有效期至：</@label></label> <input style="width: 168px" type="text" name="toDateStr" class="date"  value="<#if (user.toDateStr)??>${user.toDateStr!''}</#if>" /> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                                    </p>
                                    <p>
                                        <label><@label key="userTypeCode.C,colon">用户类型：</@label></label> <select style="width: 200px" name="userTypeECode" class="required"> <#list userType as types>
                                            <option value="${types.eCode}"<#if (user.userTypeECode)?? && (user.userTypeECode == types.eCode)> selected="selected"</#if>>${types.eCodeText}</option> </#list>
                                        </select>
                                    </p>

                                    <p>
                                        <label>&nbsp;</label> <label><input type="checkbox" name="systemFlag" value="1"<#if (user.systemFlag)?? && (user.systemFlag == 1)> checked="true"</#if>><@label key="systemFlag.C">系统内置</@label></label>
                                    </p>

                                    <p>
                                        <label>&nbsp;</label> <label><input type="checkbox" name="lockFlag" value="1"<#if (user.lockFlag)?? && (user.lockFlag == 1)> checked="true"</#if>><@label key="lock.C">锁定</@label></label>
                                    </p>
                                </div>
                                <div class="table border" width="100%" layoutH="210">
                                    <p>
                                        <label><@label key="contactName.C,colon">名称：</@label></label> <input name="contactName" value="<#if (user.contactName)??>${user.contactName!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="birthDate.C,colon">出生日期：</@label></label> <input type="text" name="birthDateStr" class="date" style="width: 168px"  value="<#if (user.birthDateStr)??>${user.birthDateStr!''}</#if>" /> <a class="inputDateButton" href="javascript:;"><@label key="select.B">选择</@label></a>
                                    </p>
                                    <p>
                                        <label><@label key="telephone.C,colon">电话：</@label></label> <input class="phone" name="telephone" value="<#if (user.telephone)??>${user.telephone!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="mobile.C,colon">移动电话：</@label></label> <input class="phone" name="mobile" value="<#if (user.mobile)??>${user.mobile!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="fax.C,colon">传真：</@label></label> <input class="phone" name="fax" value="<#if (user.fax)??>${user.fax!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="email.C,colon">E-Mail：</@label></label> <input class="email" name="email" value="<#if (user.email)??>${user.email!''}</#if>" style="width: 186px" type="text" maxlength="120" />
                                    </p>
                                    <p>
                                        <label><@label key="address.C,colon">地址：</@label></label> <input name="address" value="<#if (user.address)??>${user.address!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="postcode.C,colon">邮编：</@label></label> <input class="postcode" name="postcode" value="<#if (user.postcode)??>${user.postcode!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="wechat.C,colon">微信：</@label></label> <input class="wechat" name="wechat" value="<#if (user.wechat)??>${user.wechat!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                    <p>
                                        <label><@label key="smartWatch.C,colon">智能手表：</@label></label> <input class="smartWatch" name="smartWatch" value="<#if (user.smartWatch)??>${user.smartWatch!''}</#if>" style="width: 186px"  type="text" maxlength="60" />
                                    </p>
                                </div>
                                <div id="orgtable" style="height:252px">
                                    <div id="bar" class="pBar">
                                        <ul class="toolBar">
                                            <input id="orgid" name="orgLookup.id" type="hidden" type="text" />
                                            <input id="orgname" name="orgLookup.name" type="hidden" type="text" />
                                            <input id="orgpath" name="orgLookup.path" type="hidden" type="text" />
                                            <li><a class="add" width="640" height="500" href="${rc.getContextPath()}/manage/user/selectOrg?navTabId=${navTabId!''}" lookupGroup="orgLookup" callback="org_callback"  title="<@label key='addOrg.C'>新增组织</@label>"><span><@label key="add.B">新增</@label></span> </a>
                                            </li>
                                            <li><a href="javascript:" class="delete" onclick="orgdel()"><span><@label key="delete.B">删除</@label></span> </a>
                                            </li>
                                        </ul>
                                    </div>


                                    <table class="table border" width="100%"     <#if (user.userCode)??>layoutH="275"<#else>layoutH="205"</#if>>
                                        <thead>
                                            <tr>
                                                <th width="20"><input type="checkbox" group="ids" class="checkboxCtrl">
                                                </th>
                                                <th width="100"><@label key="organizationCode.C">组织编号</@label></th>
                                                <th width="100"><@label key="organizationText.C">组织名称</@label></th>
                                                <th width="100"><@label key="path.C">路径</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="orgtbody">
                                            <#if orgs??><#if (orgs?size>0)> <#list orgs as org>
                                            <tr id="org_${org.organizationCode!''}" target="org_code" rel="${org.organizationCode!''}">
                                                <td width="16"><input type="checkbox" name="ids" class="checkboxCtrl" value="${org.organizationCode!''}">
                                                </td>
                                                <td width="100">${org.organizationCode!''}</td>
                                                <td width="100">${org.organizationText!''}</td>
                                                <td width="100">${org.path!''}</td>
                                            </tr>
                                            </#list> </#if> </#if>
                                        </tbody>
                                    </table>

                                </div>
                                <div style="height:252px">
                                    <div id="bar" class="pBar">
                                        <ul class="toolBar">
                                            <input id="roleid" name="roleLookup.id" type="hidden" type="text" />
                                            <input id="rolename" name="roleLookup.name" type="hidden" type="text" />
                                            <li><a class="add" width="640" height="500" href="${rc.getContextPath()}/manage/user/selectRole?navTabId=${navTabId!''}" lookupGroup="roleLookup" callback="role_callback" title="<@label key='addRole.C'>新增角色</@label>"><span><@label key="add.B">新增</@label></span> </a>
                                            </li>
                                            <li><a href="javascript:" class="delete" onclick="roledel()"><span><@label key="delete.B">删除</@label></span> </a>
                                            </li>
                                        </ul>
                                    </div>


                                    <table class="table border" width="610px" <#if (user.userCode)??>layoutH="275"<#else>layoutH="205"</#if>>
                                        <thead>
                                            <tr>
                                                <th width="20"><input type="checkbox" group="rids" class="checkboxCtrl">
                                                </th>
                                                <th width="100"><@label key="roleCode.C">角色</@label></th>
                                                <th width="100"><@label key="roleText.C">描述</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="roletbody">
                                            <#if roles??><#if (roles?size>0)> <#list roles as role>
                                            <tr id="role_${role.roleCode!''}" target="role_code" rel="${role.roleCode!''}">
                                                <td width="12"><input type="checkbox" name="rids" value="${role.roleCode!''}" class="checkboxCtrl">
                                                </td>
                                                <td width="100">${role.roleCode!''}</td>
                                                <td width="100">${role.roleText!''}</td>
                                            </tr>
                                            </#list> </#if> </#if>
                                        </tbody>
                                    </table>

                                </div>
                                <div style="height:252px">
                                    <table class="table border" width="100%" <#if (user.userCode)??>layoutH="275"<#else>layoutH="205"</#if>> 
                                        <thead>
                                            <tr>
                                                <th width="100"><@label key="parameterCode.C">参数编码</@label></th>
                                                <th width="100"><@label key="parameterValue.C">参数值</@label></th>
                                                <th width="100"><@label key="parameterText.C">参数描述</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <#if paras??><#if (paras?size>0)> <#list paras as para>
                                            <tr id="${para.rolecode!''}" target="para_code" rel="${para.rolecode!''}">
                                                <td>${para.parameterCode!''}</td>
                                                <td>${para.parameterValue!''}</td>
                                                <td>${para.parameterText!''}</td>
                                            </tr>
                                            </#list> </#if> </#if>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="tabsFooter">
                                <div class="tabsFooterContent"></div>
                            </div>
                        </div>
                    </dd>
                </dl>
            </fieldset>
        </div>
        <#if (user.userCode)??> 
            <#assign createInfo=user/>
            <#include "/common/createInfo.html">
        </#if>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive" id="save">
                        <div class="buttonContent">
                            <button type="submit" onclick="c()"><@label key="save.B">保存</@label></button>
                        </div>
                    </div></li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>

    </form>
</div>

<script language="javascript">
    var page=$.pdialog.getCurrent();
    function c() {
        var org = "";
        var role = "";
        var orgtable = $("#orgtbody");
        var roletable = $("#roletbody");
        orgtable.find("tr").each(function(i, n) {
            var obj = $(n)
            org += obj.attr("id").replace("org_", "") + ",";
        });
        roletable.find("tr").each(function(i, n) {
            var obj = $(n)
            role += obj.attr("id").replace("role_", "") + ",";
        });
        if (org.length > 1) {
            org = org.substring(0, org.length - 1);
        }
        if (role.length > 1) {
            role = role.substring(0, role.length - 1);
        }
        $("#role").val(role);
        $("#org").val(org);

    }
    function org_callback() {
        var id = $("#orgid").val();
        var name = $("#orgname").val();
        var path = $("#orgpath").val();
        var idArr = new Array();
        var nameArr = new Array();
        var pathArr = new Array();
        idArr = id.split(',');
        nameArr = name.split(',');
        pathArr = path.split(',');
        var ht = "";
        for ( var i = 0; i < idArr.length; i++) {
            var orgid = idArr[i];
            var orgname = nameArr[i];
            var orgpath=pathArr[i]
            var my_element = $("#org_" + orgid,page);
            if (my_element.length == 0) {
                ht += "<tr id='org_"+orgid+"'target='org_code' rel='"+orgid+"'><td width='16'><input  name='ids' value='"+orgid+"' type='checkbox'></td><td width='100'>"
                        + orgid
                        + "</td><td width='100'>"
                        + orgname
                        + "</td><td width='100'>"
                        + orgpath
                        + "</td></tr>";
            }

        }
        $("#orgtbody").append(ht);

    }

    function orgdel() {
           var count=0;
           $('input[name="ids"]:checked').each(function(i, e) {
                count++;
            });
           if(count==0)
               {
               alertMsg.warn('<@label key="selectOrg.M">请勾选组织！</@label>')
               }
           else
               {
        alertMsg.confirm("<@label key="confirmDelOrg.M">确定要删除选中的组织吗？</@label>", {
            okCall : function() {
                $('input[name="ids"]:checked').each(function(i, e) {
                    $("#org_" + e.value).remove();
                });
            }
        });
               }
    }

    function role_callback() {
        var id = $("#roleid").val();
        var name = $("#rolename").val();
        var idArr = new Array();
        var nameArr = new Array();
        idArr = id.split(',');
        nameArr = name.split(',');
        var ht = "";
        for ( var i = 0; i < idArr.length; i++) {
            var orgid = idArr[i];
            var orgname = nameArr[i];
            var my_element = $("#role_" + orgid,page);
            if (my_element.length == 0) {
                ht += "<tr id='role_"+orgid+"'target='role_code' rel='"+orgid+"'><td width='12'><input  name='rids' value='"+orgid+"' type='checkbox'></td><td width='100'>"
                        + orgid
                        + "</td><td width='100'>"
                        + orgname
                        + "</td></tr>";
            }

        }
        $("#roletbody").append(ht);

    }

    function roledel() {
           var count=0;
           $('input[name="rids"]:checked').each(function(i, e) {
                count++;
            });
           if(count==0)
               {
               alertMsg.warn('<@label key="selectRole.M">请勾选角色！</@label>')
               }
           else
               {
        alertMsg.confirm("<@label key="confirmDelRole.M">确定要删除选中的角色吗？</@label>", {
            okCall : function() {
                $('input[name="rids"]:checked').each(function(i, e) {
                    $("#role_" + e.value).remove();
                });
            }
        });
               }
    }
</script>
